package com.yao.component.pictureselector;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.yao.component.pictureselector.adapter.ImageDirAdapter;

/**
 * Created by zwj on 2016/1/19.
 */
public class ImageDirActivity extends BaseActivity {
    private ListView mListView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image_dir_activity);
        initView();


    }
    private void initView(){
        showRightTv("取消", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                setResult(RESULT_CANCELED,intent);
                ImageDirActivity.this.finish();
            }
        });
        showTitle("照片");
        mListView=(ListView)findViewById(R.id.dir_list);
        mListView.setAdapter(new ImageDirAdapter(this, PhotoBrowseActivity.mImageFloders));
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent=new Intent();
                intent.putExtra("position",position);
                setResult(RESULT_OK,intent);
                ImageDirActivity.this.finish();
            }
        });
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        Intent intent=new Intent();
        setResult(RESULT_CANCELED,intent);
        ImageDirActivity.this.finish();
    }
}
